"""Definition of the broker content type
"""

from zope.interface import implements

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata
from Products.ATContentTypes.content.newsitem import ATNewsItem,ATNewsItemSchema


# -*- Message Factory Imported Here -*-
from my315ok.fangcan import fangcanMessageFactory as _

from my315ok.fangcan.interfaces import Ibroker
from my315ok.fangcan.config import PROJECTNAME

brokerSchema = ATNewsItemSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-

 

    atapi.StringField(
        'name',
        searchable = True,
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"name"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'phone',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"phone"),
            description=_(u""),
        ),
        required=True,
    ),


    atapi.StringField(
        'Area',
        searchable = True,
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"Area"),
            description=_(u""),
        ),
    ),
    atapi.StringField(
        'mail',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"Mail address"),
            description=_(u""),
        ),
        validators=('isEmail'),
    ),



))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

brokerSchema['title'].storage = atapi.AnnotationStorage()
brokerSchema['description'].storage = atapi.AnnotationStorage()
brokerSchema['imageCaption'].widget.visible = 0
brokerSchema['text'].widget.visible = 0

schemata.finalizeATCTSchema(brokerSchema, moveDiscussion=False)


class broker(ATNewsItem):
    """broker"""
    implements(Ibroker)

    meta_type = "broker"
    schema = brokerSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    mail = atapi.ATFieldProperty('mail')

    name = atapi.ATFieldProperty('name')

    phone = atapi.ATFieldProperty('phone')

    Area = atapi.ATFieldProperty('Area')


atapi.registerType(broker, PROJECTNAME)
